package com.itheima.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.itheima.domain.RoleMenuRelation;
import com.itheima.mapper.RoleMenuRelationMapper;
import com.itheima.service.IRoleMenuRelationService;
import org.apache.dubbo.config.annotation.DubboService;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 后台角色菜单关系表 服务实现类
 * </p>
 *
 * @author fukeke
 * @since 2022-11-11
 */
@DubboService
public class RoleMenuRelationServiceImpl extends ServiceImpl<RoleMenuRelationMapper, RoleMenuRelation> implements IRoleMenuRelationService {
    @Autowired
    RoleMenuRelationMapper roleMenuRelationMapper;

    @Override
    public List<RoleMenuRelation> findByRoleId(Long roleId) {
        LambdaQueryWrapper<RoleMenuRelation> qw = new LambdaQueryWrapper<>();
        qw.eq(RoleMenuRelation::getRoleId, roleId);
        return roleMenuRelationMapper.selectList(qw);

    }

    @Override
    public void deleteByRoleId(Long roleId) {
        LambdaQueryWrapper<RoleMenuRelation> qw =new LambdaQueryWrapper<>();
        qw.eq(RoleMenuRelation::getRoleId,roleId);
        roleMenuRelationMapper.delete(qw);
    }

    @Override
    public void saveRoleMenuRelation(RoleMenuRelation roleMenuRelation) {
        roleMenuRelationMapper.insert(roleMenuRelation);
    }
}
